home *** CD-ROM | disk | FTP | other *** search
- { Configuration routine for MAP.PAS for the PC/MS-DOS family of Turbo Pascal compilers }
-
- const MachineType = 'DOS';
- QuantizationSize = 256;
- PaddingByte = $00;
-
- var Buffer: array[1..QuantizationSize] of byte;
-
- function EndOfOverlay(var Fyle: BinaryFile;
- var Index,AmbiguousCount: integer;
- RetryCount: integer): boolean;
- { Return true if last sector of an overlay is in the buffer }
-
- function EndCheck(StartingPoint: integer): boolean;
- { Check for a valid end sequence at the indicated address }
- const SimpleReturnString = #139#229#93#195; { Look for BP, SP and RET instructions }
- ComplexReturnString1 = #139#229#93#194; { Look for BP, SP and RET nn instructions }
- ComplexReturnString2 = #139#229#93#233; { Look for BP, SP and JMP xxxx instructions (functions returning strings) }
- type ChrStr = string[4];
-
- function TestEndingPrefix(Index: integer;Ending: ChrStr): boolean;
- { Test for the ending prefix ending at the given index into Buffer (may be negative) }
- var TempBuffer: array[1..384] of char;
-
- function CompareString(var BufferAddr;TestString: ChrStr): boolean;
- { Test the string against the buffer }
- var Buffer: array[1..255] of char absolute BufferAddr;
- begin
- CompareString := copy(Buffer,1,length(TestString)) = TestString
- end;
-
- begin
- if Index < length(Ending)
- then
- if filepos(Fyle)<3
- then
- TestEndingPrefix := false { Nothing previous to look for, must return false }
- else
- begin
- seek(Fyle,filepos(Fyle)-3); { Look back at the data previous to this buffer-full }
- blockread(Fyle,TempBuffer,3); { Get data and restore file pointer }
- TestEndingPrefix := CompareString(TempBuffer[129+Index-length(Ending)],Ending)
- end
- else
- TestEndingPrefix := CompareString(Buffer[Index-length(Ending)+1],Ending)
- end;
-
- begin
- if TestEndingPrefix(StartingPoint,SimpleReturnString) { Look for a simple RET }
- then
- EndCheck := true
- else
- if TestEndingPrefix(StartingPoint-2,ComplexReturnString1) { Look for a RET nn }
- then
- EndCheck := true
- else { Handle the case of a function returning a string }
- EndCheck := TestEndingPrefix(StartingPoint-2,ComplexReturnString2) { Look for a JMP xxxx }
- end;
-
- begin
- Index := QuantizationSize;
- if EndCheck(QuantizationSize)
- then
- begin { If last byte in record is a return instruction, }
- EndOfOverlay := not odd(RetryCount shr AmbiguousCount); { Check how to handle the ambiguity this time }
- AmbiguousCount := succ(AmbiguousCount)
- end
- else
- begin { Look for a return instruction padded out with 00's }
- while (Index>=1) and (Buffer[Index]=PaddingByte) do
- Index := pred(Index);
- if Index=QuantizationSize
- then
- EndOfOverlay := false { We've already eliminated the last byte as an end point }
- else
- if EndCheck(Index+1)
- then
- begin
- EndOfOverlay := true; { In this case the last byte of the RET nn instruction was a 0 }
- Index := succ(Index)
- end
- else
- if Index=0
- then
- EndOfOverlay := false { This assumes that there is no such thing as a RET 0 }
- else
- EndOfOverlay := EndCheck(Index)
- end
- end;
-
- procedure CheckVersion;
- { This routine is not executed, it only serves to check that the correct
- configuration module is being used. }
-
-
-
-
-
- (******************************************************************************
- You are attempting to compile this program with the wrong
- configuration file. You need to change the include file
- directive located about 20 lines from the beginning of
- MAP.PAS to:
- {$I MAPCPM.PAS}
- ******************************************************************************)
-
-
-
-
-
-
- var Address: byte absolute $0000:$0000;
- begin
- end;